package leetcode.剑指offer.前40;

import org.junit.Test;

/**
 * @author :songyaozhang
 * @date :Created 2021/7/22 15:27
 * @description :https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/
 */
public class 剑指_10_II_青蛙跳台阶问题 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.numWays(7));
    }

    class Solution {
        public final int MOD = 1000000007;

        public int numWays(int n) {
            switch (n) {
                case 0:
                case 1:
                    return 1;
                case 2:
                    return 2;
            }
            int[] nums = new int[n + 1];
            nums[1] = 1;
            nums[2] = 2;
            for (int i = 3; i <= n; i++) {
                nums[i] = (nums[i - 1] + nums[i - 2]) % MOD;
            }
            return nums[n];
        }
    }
}
